package com.syg.servlet09_Ajax;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/getHtmlAjax")
public class _01_GetHTMLAjax extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("1111111111111111111");
        this.getServletContext().getRequestDispatcher("/WEB-INF/JspPage/servlet09_Ajax/Ajax.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        OutputStream os = resp.getOutputStream();
        List<Object> list = new ArrayList<Object>();
        list.add("hello");
        list.add("gray");
        os.write(list.toString().getBytes());
    }
}
